<template>
  <div id="app"  @click="clicked()">
    <router-view/>
  </div>
</template>
<script>
    export default {
        data(){
            return{
                lTime: new Date().getTime(), // 最后一次点击的时间
                cTime: new Date().getTime(), //当前时间
                tOut: 10 * 60 * 1000, //超时时间10min
                t1: ''
            }
        },
        mounted(){
            // this.t1 = setInterval(this.tTime, 1000);
        },
        methods:{
            clicked () {
                this.lTime = new Date().getTime()  //当界面被点击更新点击时间
            },
            tTime() {
                this.cTime = new Date().getTime();
                if (this.cTime - this.lTime > this.tOut) {
                    //未登录状态
                    if (!window.sessionStorage.getItem('token')) {
                        this.lTime = new Date().getTime();
                    } else {
                        this.$store.commit('logOut')
                        this.$router.push({name: 'login'})
                    }
                }
            }
        }
    }
</script>
<style lang='stylus'>
    .fade-enter-active, .fade-leave-active {
        transition: opacity .5s;
    }
    .fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ {
        opacity: 0;
    }
</style>

<style lang="stylus">
    @import './assets/css/reset.styl'
    @import './assets/css/map.styl'
    @import './assets/css/elementReset.styl'
    @import './assets/css/font.css'
    #app{
        height: 100%;
    }
</style>
